package week04;
    public class Newequals {

        public static void main(String[] args) {
        	Fruit Fruit1=new Fruit("lili");
        	Fruit Fruit2=new Fruit("LiLi");
        	Fruit Fruit3=new Fruit("nini");
        	System.out.println(Fruit1.equals(Fruit2));
            System.out.println(Fruit2.equals(Fruit3));
        	}
        }
        
    class Fruit{
        private String name;
        public Fruit(String name){
            this.name = name;
        }
        public String toString() {
            return name;
        }
        @Override
        public int hashCode() {
            final int prime = 31;
            int result = 1;
            result = prime * result + ((name == null) ? 0 : name.hashCode());
            return result;
        }
        @Override
        public boolean equals(Object obj) {
            if (this == obj)
                return true;
            if (obj == null)
                return false;
            if (getClass() != obj.getClass())
                return false;
            Fruit other = (Fruit) obj;
            if (name == null) {
                if (other.name != null)
                    return false;
            } else if (!name.equalsIgnoreCase(other.name))
                return false;
            return true;
        }
        
    }
